﻿@model List<string>
<input type="hidden" id="fcdbTemplateType" name="fcdbTemplateType" value="@Request["templateType"]" />
<table class="tb-search mb10" style="width: 100%;">
    <tr>
        <td class="box ">
            @(Request["templateType"] == "0" ? "协议模板" : "合同模板")：<select id="tempdateName" name="tempdateName" class="input-style-txt form-select">
                @foreach (var item in Model)
                {
                    <option value="@item">
                        @item
                    </option>
                }
            </select>
            <input type="button" id="btnConfirm" value='@(Request["templateType"] == "0" ? "生成协议" : "生成合同")' class="btn btn-blue " />
        </td>
    </tr>

</table>
<script src='@Url.Content("~/Scripts/jquery-1.8.2.min.js")'></script> 
<script type="text/javascript">
    $(function () {
        $("#btnConfirm").click(function () {
            if ($("#tempdateName").find("option:selected").text() == "") {
                alert("请选择要打印的模板");
                return;
            }

            if ('@Request["templateType"]' == "1") {
                var url = '@Url.Action("PrintFall", "word")' + '?formID=@Request["formID"]&&templateName=' + $("#tempdateName").find("option:selected").text();;
                $.post(url, function (data) {
                    if (data.Status == 0) {
                        url = '@Url.Action("Fall", "ContractFolder")' + '/@Request["formID"]' + ".doc";
                        window.open(url);
                        window.top.oDG.close();
                    } else {
                        alert(data.Message);
                    }
                });
            } else {
                var url = '@Url.Action("PrintAgreement", "word")' + '?formID=@Request["formID"]&&templateName=' + $("#tempdateName").find("option:selected").text();;
                $.post(url, function (data) {
                    if (data.Status == 0) {
                        url = '@Url.Action("Agreement", "ContractFolder")' + '/@Request["formID"]' + ".doc"; 
                        window.open(url);
                        window.top.oDG.close();
                    } else {
                        alert(data.Message);
                    }
                });
            }
        })
    });
</script>
